﻿<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title>拼图后台管理-管理员登录</title>
		<link rel="stylesheet" href="css/pintuer.css">
		<link rel="stylesheet" href="css/admin.css">
		<link rel="stylesheet" href="css/dayong.css">
		<script src="js/jquery.js"></script>
		<script src="js/qh_wy.js"></script>
		<script src="js/pintuer.js"></script>
		<script src="js/admin.js"></script>
		<link type="image/x-icon" href="http://www.pintuer.com/favicon.ico" rel="shortcut icon" />
		<link href="http://www.pintuer.com/favicon.ico" rel="bookmark icon" />
	</head>

	<body>
		<div id="flag" style="display:none">${flag}</div> 
		<div class="container content">
			<div class="line">
				<div class="xs6 xm4 xs3-move xm4-move">
					<div class="media media-y">
						<a href="indexFront.jsp" target="_blank"><img src="images/logo.png" class="radius" alt="后台管理系统" /></a>
					</div>
					<form action="loginCheckServlet" method="post">
						<div class="panel">
							<div class="panel-head"><strong>登录大勇网站</strong></div>
							<div class="panel-body" style="padding:30px;">
								<div class="form-group">
									<div class="field field-icon-right">
										<input id="username" type="text" class="input" name="username" placeholder="登录账号" />
										<span class="icon icon-user"></span>
									</div>
								</div>
								<div class="form-group">
									<div class="field field-icon-right">
										<input id="password" type="text" class="input" name="password" placeholder="登录密码" />
										<span class="icon icon-key"></span>
									</div>
								</div>
							</div>
							<div class="panel-foot text-center">
								<button class="button button-block bg-main text-big" type="submit">立即登录后台</button>
							</div>
							<div style="padding-left:20px">没有账号，<a href="register.jsp" style="color:red;">快去注册</a></div>
						</div>
					</form>
					<div class="panel-foot text-center">
						<button class="button button-block bg-main text-big" id="login">立即登录后台ajax</button>
					</div>
					<div class="text-right text-small text-gray padding-top" id="jiyu">基于大勇先森构建</div>
				</div>
			</div>
		</div>
	</body>
	<script>
		function checkFileType(){
			//alert($("#flag").html());
			if($("#flag").html()=='false'){
				alert("账号或者密码错误，请重新输入！");
			}else{
				//alert("文件格式對！");
			}
		}
		if($("#flag").html()){
			checkFileType();
		}
		document.getElementById("username").focus();
		
		$("#login").click(function(){
			//alert(888);
			var username = $('input[name="username"]').val();
			var password = $('input[name="password"]').val();
			if(username && password){
				var url = getUrl()+'/testServlet';
				//alert(url);
				console.log(url);
					 $.ajax({
					   type: "post",
					   url: url,
					   dataType: 'json',
						data: {
							'username':username,
							'password':password
						},
					   beforeSend: function (xhr) {
					   },
					   success: function (data) {
						  	 $("#jiyu").html(data[0].imgName);
							//alert(data[0].imgName);
							//alert(typeof(data));
						   //console.log(data);
					   },
					   error: function (jqXHR, textStatus, errorThrown) {
					  		 alert("错误提示!!!!");
					   }
					}); 
			}else{
				alert("账号或者密码为空！！！");
				return false;
			}
		});
	</script>
</html>